 var infowindow;
 var map;
 
 var baseURL ="https://labs.commutegreenerinfo.com/it/";
 
 
 
  function initializeStartMap() {
	  
	  
	  //var city = document.getElementById("city");
	  
	  var radius = document.getElementById("sRadius").value;
	 
	  
	  if(radius<15000){
	  var myOptions1 = {
				center : new google.maps.LatLng(57.70779280783442, 11.937975883483887),
				zoom : 10,
				mapTypeId : google.maps.MapTypeId.ROADMAP
			};
			//gothenburg center
			var myOptions2 = {
				center : new google.maps.LatLng(19.429413676234212, -99.12683863302618),
				zoom : 10,
				mapTypeId : google.maps.MapTypeId.ROADMAP
			};
	  
	  }
	  
	  else{
		  
		  var myOptions1 = {
					center : new google.maps.LatLng(57.70779280783442, 11.937975883483887),
					zoom : 8,
					mapTypeId : google.maps.MapTypeId.ROADMAP
				};
				//gothenburg center
				var myOptions2 = {
					center : new google.maps.LatLng(19.429413676234212, -99.12683863302618),
					zoom : 8,
					mapTypeId : google.maps.MapTypeId.ROADMAP
				};
		  
		  
	  }
	  if(document.getElementById("city").value == "mexico"){
		  map = new google.maps.Map(document.getElementById("map_canvas"),myOptions2);
			
	  }else if(document.getElementById("city").value == "gothenborg"){
		  map = new google.maps.Map(document.getElementById("map_canvas"),
					myOptions1);
		  
	  }
//    var myLatlng = new google.maps.LatLng(57.70779280783442, 11.937975883483887);
//    var myOptions = {
//      zoom: 10,
//      center: myLatlng,
//      mapTypeId: google.maps.MapTypeId.ROADMAP
//    }
    
   
   // map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    downloadUrl("js/startLocation.xml", function(data) {
    	//"js/moredata.xml"  "js/Location.xml"  C:/files/Location.xml
      var markers = data.documentElement.getElementsByTagName("marker");
      for (var i = 0; i < markers.length; i++) {
        var latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
        var marker = createMarker(markers[i].getAttribute("name"), latlng);
       }
     });
    $('#auto-button').hide(); 
   $('#auto-button').trigger('onclick');
   
  }
  
//  function createMarker(name, latlng) {
//	    var marker = new google.maps.Marker({position: latlng, map: map});
//	    google.maps.event.addListener(marker, "click", function() {
//	      if (infowindow) infowindow.close();
//	      infowindow = new google.maps.InfoWindow({content: name});
//	      infowindow.open(map, marker);
//	    });
//	    
//	    if(name =="BUS"){
//	    	iconFile = 'images/black.png'; 
//	    }
//	    else if(name =="CAR"){
//	    	iconFile = 'images/red.png'; 
//	    }
//	    else if(name =="BICYCLE"){
//	    	iconFile = 'images/green.png'; 
//	    }
//	    else if(name =="WALKING"){
//	    	iconFile = 'images/purple.png'; 
//	    }
//	    else if(name =="FERRY"){
//	    	iconFile = 'images/blue.png'; 
//	    }
//	    else if(name =="TRAIN_SUBWAY_METRO"){
//	    	iconFile = 'images/pink.png'; 
//	    }
//	    else if(name =="AEROPLANE"){
//	    	iconFile = 'images/silver.png'; 
//	    }
//	    else if(name =="DESTINATION"){
//	    	iconFile = 'images/check_flag.png'; 
//	    }
//	    
//	    marker.setIcon(iconFile) ;
//	    return marker;
//	  }
  

//code logic has been changed
  function createMarker(name, latlng) {

		var iconFile;
		if (name == "BUS") {
			iconFile = "images/black.png";
		} else if (name == "CAR") {
			iconFile = 'images/red.png';
		} else if (name == "BICYCLE") {
			iconFile = 'images/green.png';
		} else if (name == "WALKING") {
			iconFile = 'images/purple.png';
		} else if (name == "FERRY") {
			iconFile = 'images/blue.png';
		} else if (name == "TRAIN_SUBWAY_METRO") {
			iconFile = 'images/pink.png';
		} else if (name == "AEROPLANE") {
			iconFile = 'images/silver.png';
		}
	    else if(name =="DESTINATION"){
	    	iconFile = 'images/check_flag.png'; 
	    }
		
		var marker = new google.maps.Marker({
			position : latlng,
			map : map,
			icon : baseURL+iconFile
		});

		google.maps.event.addListener(marker, "click", function() {
			if (infowindow)
				infowindow.close();
			infowindow1 = new google.maps.InfoWindow({
				content : name
			});
			infowindow.open(map, marker);
		});
	}

